package com.boot.feign.fallback;

import com.boot.feign.ProductFeignClient;
import com.boot.product.pojo.Product;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

@Component
public class ProductFeignClientFallBack implements ProductFeignClient {
    //只有在拿不到的时候才会调用
    @Override
    public Product getProduct(Long id) {
        System.out.println("兜底返回数据");
        Product product = new Product();
        product.setId(id);
        product.setPrice(new BigDecimal("0"));
        product.setProductName("未知商品");
        product.setNum(0);
        return product;
    }
}
